package editor;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class DialogErrore extends JDialog implements ActionListener {
	int tipo;
	JLabel testoErrore;
	JButton ok;
	
	public DialogErrore(int tipo){
		this.tipo = tipo;
		JPanel pann = new JPanel();
		testoErrore = new JLabel();
		stampaErrore();
		ok = new JButton("Ok");
		ok.setPreferredSize(new Dimension(90,30));
		ok.addActionListener(this);
		pann.add(testoErrore);
		pann.add(ok);
		this.setContentPane(pann);
		this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		this.setTitle("Attenzione");
		this.setSize(testoErrore.getSize());
		this.setLocation(500,300);
		this.setAlwaysOnTop(true);
		this.setVisible(true);
	}
	
	private void stampaErrore(){
		if (tipo == 0){
			testoErrore.setText("Mattone selezionato appartentente ad un tile-set diverso da quelli in uso.");
			testoErrore.setSize(new Dimension(430,110));
		}
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == ok){
			this.dispose();
		}
	}
	
}
